package com.wen.yygh.hosp.controller;

import com.wen.yygh.common.result.Result;
import com.wen.yygh.hosp.service.HospitalService;
import com.wen.yygh.model.hosp.Hospital;
import com.wen.yygh.vo.hosp.HospitalQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.sql.ResultSet;

/**
 * @author Wenjl
 */
@RestController
@RequestMapping("/admin/hosp/hospital")

@Api(tags = "医院管理")
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;

    @GetMapping("list/{pageNum}/{pageSize}")
    @ApiOperation("获得全部医院列表")
    public Result hospList(@PathVariable("pageNum") Integer pageNum,
                           @PathVariable("pageSize") Integer pageSize,
                           HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> hospitalPage = hospitalService.findHospPageByHospitalQueryVo(pageNum, pageSize, hospitalQueryVo);
        return Result.ok(hospitalPage);
    }

    @PostMapping("updateStatus/{id}/{status}")
    @ApiOperation("修改医院状态")
    public Result updateStatusById(@PathVariable("id") String id,
                                   @PathVariable("status") Integer status) {

        hospitalService.updateStatusById(id, status);
        return Result.ok();
    }

    @GetMapping("showHospital/{id}")
    public Result findHospitalById(@PathVariable("id") String id) {
        Hospital hospital = hospitalService.findHospitalById(id);
        return Result.ok(hospital);
    }
}
